// 3.bridge典型应用之整体与局部
function Position(x, y) {
    this.x = x;
    this.y = y;
}
function CircleColor(color) {
    this.color = color;
}

function Circle(x, y, color) {
    this.Position = new Position(x, y);
    this.Color = new CircleColor(color);
}

Circle.prototype = {
    render() {
        let canvas = document.getElementById('canvas');
        let ctx = canvas.getContext('2d');
        ctx.beginPath();
        ctx.arc(this.Position.x, this.Position.y, 100, 0, 2*Math.PI);
        ctx.fillStyle = this.Color.color;
        ctx.fill();
        ctx.closePath();
    }
};

let ball = new Circle(200, 200, 'red');
ball.render();